package com.byxy.ssm.demo.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;

import com.byxy.ssm.demo.entity.Items;
import com.byxy.ssm.demo.service.ItemsService;

@RequestMapping("items")
@Controller
public class ItemsCotroller {
	
	@Autowired
	private ItemsService ItemsService;
	
	@RequestMapping("add")
	public String add(Items items,MultipartFile file,HttpServletRequest request) {
		ItemsService.add(items, file, request);
		return "redirect:list";
	}
	
	@RequestMapping("/list")
	public void findItems(Model model) {
		model.addAttribute("list", ItemsService.getAll());
	}
}
